<html>
<head><meta charset="utf-8"><title>Adding regex dependency in `test` · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html">Adding regex dependency in `test`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225425947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225425947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jasonoro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225425947">(Feb 06 2021 at 19:14)</a>:</h4>
<p>Hi all,<br>
I'm working on adding regex support to test filters, see also <a href="https://github.com/rust-lang/rust/issues/53278">https://github.com/rust-lang/rust/issues/53278</a>. I've however run into a issue I'd like some feedback on. I would like to add the <code>regex</code> crate to the <code>Cargo.toml</code> of <code>test</code>, however this is not possible since <code>regex</code> depends on <code>core</code> and <code>std</code>. Adding the following to the <code>Cargo.toml</code> (std is required to do anything with regex):</p>
<div class="codehilite"><pre><span></span><code>regex = { version = &quot;1&quot;, default-features = false, features = [&#39;std&#39;] }
</code></pre></div>
<p>results in the following error:</p>
<div class="codehilite"><pre><span></span><code>    Checking regex-syntax v0.6.22
error[E0463]: can&#39;t find crate for `std`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `regex-syntax`
</code></pre></div>
<p>Other dependencies, like <code>cfg-if</code> and <code>getopts</code> resolve this with <a href="https://github.com/rust-lang/getopts/blob/master/Cargo.toml#L25">a <code>rustc-dep-of-std</code> feature</a>. However, the <code>regex</code> crate doesn't have this feature, and I'm also not quite sure how selecting this feature solves the underlying problem. So I end up with 2 questions:</p>
<ol>
<li>Is there a way to use the <code>regex</code> crate in <code>test</code>? If so, does this require making a <code>rustc-dep-of-std</code> feature for <code>regex</code>?</li>
<li>How does the feature actually solve the problem? Due to the use of the <code>rustc-std-workspace-std</code> package?</li>
</ol>
<p>Thanks in advance :)</p>



<a name="225428441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225428441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225428441">(Feb 06 2021 at 20:18)</a>:</h4>
<p>The answer to the second question is yes.</p>



<a name="225438669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225438669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225438669">(Feb 07 2021 at 01:10)</a>:</h4>
<blockquote>
<p>std is required to do anything with regex</p>
</blockquote>
<p>That will probably need to be changed then, std can't depend on a crate unless it's no_std</p>



<a name="225463132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225463132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jasonoro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225463132">(Feb 07 2021 at 13:01)</a>:</h4>
<p>I had some feeling that would be the case. I'll update the issue so that's clear.</p>



<a name="225563136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225563136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225563136">(Feb 08 2021 at 15:48)</a>:</h4>
<p>The answer to your first question is also yes.</p>



<a name="225563181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225563181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225563181">(Feb 08 2021 at 15:49)</a>:</h4>
<p>You'd have to add such a feature to regex.</p>



<a name="225563703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225563703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225563703">(Feb 08 2021 at 15:52)</a>:</h4>
<p>(I would personally reach out to T-libs, perhaps on <a class="stream" data-stream-id="219381" href="/#narrow/stream/219381-t-libs">#t-libs</a> - I am not sure we would accept an expansion to include regex filters to libtest. I myself am mildly negative on doing so; it is a pretty significant increase in complexity).</p>



<a name="225615330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/225615330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#225615330">(Feb 08 2021 at 22:01)</a>:</h4>
<p>Could this maybe be another crate that extends test and is then used by cargo? E.g. test could have some simpler API to enumerate/filter cases and the regex matching could happen somewhere else.</p>



<a name="226364542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Adding%20regex%20dependency%20in%20%60test%60/near/226364542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jasonoro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Adding.20regex.20dependency.20in.20.60test.60.html#226364542">(Feb 15 2021 at 10:05)</a>:</h4>
<p>I'm going to move this discussion to <a class="stream" data-stream-id="219381" href="/#narrow/stream/219381-t-libs">#t-libs</a> . Might be a good idea to have a small discussion about this.</p>
<p>Edit: See <a href="#narrow/stream/219381-t-libs/topic/Regex.20support.20for.20libtest/near/226365353">here</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>